package com.neoCalf.neoUser.pro;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


/**
 * @author 小牛
 * @version 1.0
 * @description TODO
 * @date 2025/4/17 13:45
 */
@Component
@Data
@NoArgsConstructor
public class SocketPro {
    @Value("${socket.port}")
    private Integer port;
    @Value("${socket.heartBeatTime}")
    private Integer heartBeatTime;
    @Value("${socket.context-path}")
    private String contextPath;
    @Value("${socket.APPLY_INFO_SAVE_DAY}")
    private Integer APPLY_INFO_SAVE_DAY;
    @Value("${socket.MESSAGE_CLEAR_DAY}")
    private Integer MESSAGE_CLEAR_DAY;
    @Value("${socket.MESSAGE_QUERY_MAX_DAY}")
    private Integer MESSAGE_QUERY_MAX_DAY;
    @Value("${socket.ip}")
    private String ip;
    @Value("${socket.ClusterName}")
    private String clusterName;
    @Value("${socket.serviceName}")
    private String serviceName;

    public Integer getHeartBeatTime() {
        if (heartBeatTime == null || heartBeatTime < 3) {
            heartBeatTime = 6;
        }
        return heartBeatTime;
    }

    public long GET_APPLY_INFO_SAVE_MS() {
        return INIT_TIME(APPLY_INFO_SAVE_DAY, 30);
    }

    public long GET_MESSAGE_CLEAR_MS() {
        return INIT_TIME(MESSAGE_CLEAR_DAY, 30);
    }

    public long GET_MESSAGE_QUERY_MAX_MS() {
        return INIT_TIME(MESSAGE_QUERY_MAX_DAY, 3);
    }

    public long INIT_TIME(Integer DAY, Integer DEFAULT) {
        if (DAY == null || DAY < 0) {
            DAY = DEFAULT;
        }
        long time = DAY * 60 * 60 * 24 * 1000;
        String substring = String.valueOf(time).substring(1);
        return Long.parseLong(substring);
    }
}
